'use strict';
// Copyright 2014 Blueant Inc. All Rights Reserved.

/**
 * @fileoverview 掠夺
 * @author sundbcn@gmail.com (sun debing)
 */

var dataApi = require('../libs/dataApi');
var terrainType = require('../consts/terrainType');

/**
 * 判断是否是水路
 * @param  {[type]} vip [description]
 * @return {[type]}     [description]
 */
exports.isRoad = function (terrain_id) {
    var pvp_terrain_conf = dataApi.pvp_config.findById(terrain_id);
    return pvp_terrain_conf.island_id == terrainType.ROAD;
};

/**
 * 是否是岛
 * @param  {[type]}  terrain_id [description]
 * @return {Boolean}            [description]
 */
exports.isIsland = function (terrain_id) {
    var pvp_terrain_conf = dataApi.pvp_config.findById(terrain_id);
    return pvp_terrain_conf.island_id == terrainType.ROAD;
};

/**
 * 获取pvp星级配置(繁荣度百分值，军功获得值)
 * @param  {[type]}  star [description]
 */
exports.getPvpStarConf = function (star) {
    if (!star || star < 1) {
        console.error('获取pvp星级配置(繁荣度百分值，军功获得值 type can not found:' + star);
        return null;
    }
    return dataApi.pvp_star.findById(star);
};

/**
 * 获取军功区间分段
 * @param  {[type]}  star [description]
 */
exports.getHonorLvl = function (honor) {
    return dataApi.honor_lvl.find(function (item) {
        return item.min_honor <= honor && honor <= item.max_honor;
    });
};
